using System;
using System.Collections.Generic;
using System.Text;
using EntityLayer;
using DataAccessLayer;
using System.Data;

namespace DataLayer
{
    public class datSearchParameters
    {
        #region  Code Factory Generated Methods
        public void DeleteSearchParametersBySearchParameterId(entSearchParameters parEntSearchParameters, DbConnector parDbConnector)
        {
            DbParamCollection insDbParamCollection = new DbParamCollection();
            insDbParamCollection.Add("@pSearchParameterId", parEntSearchParameters.SearchParameterId);
            parDbConnector.ExecuteNonQuery("DeleteSearchParametersBySearchParameterId", insDbParamCollection);
        }
        public void InsertSearchParameters(entSearchParameters parEntSearchParameters, DbConnector parDbConnector)
        {
            DbParamCollection insDbParamCollection = new DbParamCollection();
            insDbParamCollection.Add("@pSearchParameterId", parEntSearchParameters.SearchParameterId);
            insDbParamCollection.Add("@pSearchDescription", parEntSearchParameters.SearchDescription);
            insDbParamCollection.Add("@pSearchPoint", parEntSearchParameters.SearchPoint);
            insDbParamCollection.Add("@pSearchResultAddress", parEntSearchParameters.SearchResultAddress);
            insDbParamCollection.Add("@pResultType", parEntSearchParameters.ResultType);
            insDbParamCollection.AddOutput("@pSearchParameterId", DbType.Int32);
            parDbConnector.ExecuteNonQuery("InsertSearchParameters", insDbParamCollection);
            parEntSearchParameters.SearchParameterId = Convert.ToInt32(insDbParamCollection.GetOutPutParameter().Value);
        }
        public void UpdateSearchParametersBySearchParameterId(entSearchParameters parEntSearchParameters, DbConnector parDbConnector)
        {
            DbParamCollection insDbParamCollection = new DbParamCollection();
            insDbParamCollection.Add("@pSearchParameterId", parEntSearchParameters.SearchParameterId);


            insDbParamCollection.Add("@pSearchDescription", parEntSearchParameters.SearchDescription);
            insDbParamCollection.Add("@pSearchPoint", parEntSearchParameters.SearchPoint);
            insDbParamCollection.Add("@pSearchResultAddress", parEntSearchParameters.SearchResultAddress);
            insDbParamCollection.Add("@pResultType", parEntSearchParameters.ResultType);
            parDbConnector.ExecuteNonQuery("UpdateSearchParametersBySearchParameterId", insDbParamCollection);
        }
        public DataTable SelectSearchParameters(DbConnector parDbConnector)
        {

            return parDbConnector.ExecuteDataTable("SelectSearchParameters", null);
        }
        public void SelectSearchParametersBySearchParameterId(entSearchParameters parEntSearchParameters, DbConnector parDbConnector)
        {
            DbParamCollection insDbParamCollection = new DbParamCollection();
            insDbParamCollection.Add("@pSearchParameterId", parEntSearchParameters.SearchParameterId);
            DataTable insDataTable = new DataTable();
            insDataTable = parDbConnector.ExecuteDataTable("SelectSearchParametersBySearchParameterId", insDbParamCollection);
            if (insDataTable.Rows.Count > 0)
            {
                if (insDataTable.Rows[0]["SearchParameterId"] != DBNull.Value)
                {
                    parEntSearchParameters.SearchParameterId = Convert.ToInt32(insDataTable.Rows[0]["SearchParameterId"]);
                }
                if (insDataTable.Rows[0]["SearchDescription"] != DBNull.Value)
                {
                    parEntSearchParameters.SearchDescription = insDataTable.Rows[0]["SearchDescription"].ToString();
                }
                if (insDataTable.Rows[0]["SearchPoint"] != DBNull.Value)
                {
                    parEntSearchParameters.SearchPoint = Convert.ToInt32(insDataTable.Rows[0]["SearchPoint"]);
                }
                if (insDataTable.Rows[0]["SearchResultAddress"] != DBNull.Value)
                {
                    parEntSearchParameters.SearchResultAddress = insDataTable.Rows[0]["SearchResultAddress"].ToString();
                }
                if (insDataTable.Rows[0]["ResultType"] != DBNull.Value)
                {
                    parEntSearchParameters.ResultType = insDataTable.Rows[0]["ResultType"].ToString();
                }
            }
        }

        #endregion
    }
}
